home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1833 / 1833.xpi / components / library-loader.js < prev    next >
Text File  |  2009-12-16  |  1KB  |  36 lines

  1. const Cc = Components.classes;
  2. const Ci = Components.interfaces;
  3. const Cu = Components.utils;
  4.  
  5. // The bulk of this function was taken from:
  6. //
  7. // http://code.google.com/p/gears/source/browse/trunk/gears/base/firefox/static_files/components/stub.js
  8.  
  9. function NSGetModule() {
  10.   return {
  11.     registerSelf: function(compMgr, location, loaderStr, type) {
  12.       var appInfo = Cc["@mozilla.org/xre/app-info;1"]
  13.                     .getService(Ci.nsIXULAppInfo);
  14.       var runtime = Cc["@mozilla.org/xre/app-info;1"]
  15.                     .getService(Ci.nsIXULRuntime);
  16.  
  17.       var osDirName = runtime.OS + "_" + runtime.XPCOMABI;
  18.       var platformVersion = appInfo.platformVersion.substring(0, 5);
  19.       var libFile = location.parent.parent;
  20.       libFile.append("lib");
  21.       libFile.append(osDirName);
  22.       libFile.append(platformVersion);
  23.       
  24.       if (!libFile.exists()) return;
  25.       
  26.       // Note: we register a directory instead of an individual file because
  27.       // Gecko will only load components with a specific file name pattern. We
  28.       // don't want this file to have to know about that. Luckily, if you
  29.       // register a directory, Gecko will look inside the directory for files
  30.       // to load.
  31.       compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar);
  32.       compMgr.autoRegister(libFile);
  33.     }
  34.   };
  35. }
  36.